from flask import Blueprint, session, redirect, request, url_for

# 创建蓝图对象
admin_blu = Blueprint('admin', __name__,url_prefix='/admin')

from . import views


@admin_blu.before_request
def before_request():
    # 判断如果不是登录页面的请求
    is_admin = session.get("is_admin", False)
    if not is_admin and not request.url.endswith(url_for("admin.login")):
        return redirect('/')

